package org.yan.stock.server.client;

import org.yan.stock.server.util.MathUtil;

/**
 * @Func Mapping the client's stock
 * @author yanxuxin_sz
 * @Date 2010-12-20
 */
public class Stock {

	private String name;
	
	private String code;
	
	private double curValue;
	
	private double offset;
	
	private double latch;
	
	private String datetime;
	
	private boolean hasMsg;
	
	private String board;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public double getCurValue() {
		return curValue;
	}

	public void setCurValue(double curValue) {
		this.curValue = curValue;
	}

	public double getOffset() {
		return offset;
	}

	public void setOffset(double offset) {
		this.offset = offset;
	}

	public double getLatch() {
		return latch;
	}

	public void setLatch(double latch) {
		this.latch = latch;
	}

	public String getDatetime() {
		return datetime;
	}

	public void setDatetime(String datetime) {
		this.datetime = datetime;
	}

	public boolean hasMsg() {
		return hasMsg;
	}

	public void setHasMsg(boolean hasMsg) {
		this.hasMsg = hasMsg;
	}

	public String getBoard() {
		StringBuilder sb = new StringBuilder("");
		if(this.hasMsg) {
			sb.append(this.name);
			if(this.offset > 0) {
				sb.append("跌");
			}
			else {
				sb.append("涨");
			}
			sb.append(MathUtil.perc2Str(this.offset));
			sb.append(",");
			sb.append("交易时间为");
			sb.append(this.datetime);
		}
		this.board =  sb.toString();
		return board;
	}
	
	public void setBoard(String board) {
		this.board = board;
	}

	public static void main(String[] args) {
		Stock stock = new Stock();
		stock.setName("深发展A");
		stock.setHasMsg(true);
		stock.setOffset(-0.0156);
		stock.setDatetime("15:05:30");
		System.out.println(stock.getBoard());
	}
	
}
